package S13.first;
import java.util.*;
import java.util.Map.Entry;
public class F03 {
	public static void main(String[] args) {
		Map<String, Person> map=new HashMap<>();
		map.put("410823198605180034", new Person("zhangsan",20)); //键是身份证号，值是Person
		map.put("411023198109107513", new Person("lisi",22));
		map.put("410105198408250215", new Person("wangwu",18));
		System.out.println("利用Iterator来显示：");
		Iterator<Entry<String, Person>> it = map.entrySet().iterator();
		while(it.hasNext()) { //还有数据吗？
			Entry<String, Person> e = it.next(); //获取数据
			System.out.println(e.getKey()+"\t"+e.getValue()); //显示数据
		}
		
		System.out.println("\n利用forEach来显示：");
		map.forEach((k,v)->System.out.println(k+"\t"+v));
		
		map.entrySet().removeIf(e->e.getValue().getAge()<22);
		System.out.println("\n利用removeIf删除集合中小于22的元素：");
		map.forEach((k,v)->System.out.println(k+"\t"+v));
	}
}
